@extends('layouts.app')

@section('content')
<h3 class="page-title">@_lang('title')</h3>

{!! Form::model($role, ['method' => 'PUT', 'route' => ['admin.manage.roles.update', $role->id]]) !!}

<div class="panel panel-default">
    <div class="panel-heading">
        @lang('global.app_edit')
    </div>

    <div class="panel-body">
        <div class="row">
            <div class="col-xs-12 form-group">
                {!! Form::label('name', _lang('fields.name').'*', ['class' => 'control-label']) !!}
                {!! Form::text('name', old('name'), ['class' => 'form-control', 'placeholder' => '', 'required' => '']) !!}
                <p class="help-block"></p>
                @if($errors->has('name'))
                <p class="help-block">
                    {{ $errors->first('name') }}
                </p>
                @endif
            </div>
        </div>
        <!-- <div class="row">
                <div class="col-xs-12 form-group">
                    {!! Form::label('permission', 'Permissions', ['class' => 'control-label']) !!}
                    {!! Form::select('permission[]', $permissions, old('permission') ? old('permission') : $role->permissions()->pluck('name', 'name'), ['class' => 'form-control select2', 'multiple' => 'multiple']) !!}
                    <p class="help-block"></p>
                    @if($errors->has('permission'))
                        <p class="help-block">
                            {{ $errors->first('permission') }}
                        </p>
                    @endif
                </div>
            </div> -->



        <div class="row">
            <div class="col-xs-12 form-group">
                {!! Form::label('permission', _lang('fields.check_permission'), ['class' => 'control-label']) !!}

                @foreach($classify as $cl_k => $cla)
                <div class="">
                    <div class="col-xs-6 form-group">

                        <div class="box box-success">

                            <div class="classify-group">
                                <div class="box-header">
                                    <h3 class="box-title">
                                        <label>
                                            <input type="checkbox" class="minimal">
                                            {{$cla['title']}}
                                        </label>
                                    </h3>
                                </div>
                                @if(!empty(count($cla->classifyHasMany)))
                                @foreach($cla->classifyHasMany as $clss_k => $class)
                                <div class="box-body">
                                    <div class="form-group">
                                        <span class="classify">
                                            <label>
                                                <input type="checkbox" class="minimal">
                                                {{$class['title']}}
                                            </label>
                                        </span>
                                        <span class="permission">
                                            @if(!empty(count($class->hasManyDetails)))
                                            @foreach($class->hasManyDetails as $per_k => $per)
                                            <label>
                                                <input type="checkbox" class="minimal" name="permission[]" value="{{$per['name']}}" @if(!empty(count($permissions))) @foreach($permissions as $permission_k=> $permission)
                                                @if($permission ==$per['name'])
                                                checked='checked'
                                                @endif
                                                @endforeach
                                                @endif
                                                />

                                                @if(!empty($per->hasDetails))
                                                {{$per->hasDetails['explain']}}
                                                @else
                                                {{$per['name']}}
                                                @endif
                                            </label>
                                            @endforeach
                                            @endif
                                        </span>
                                    </div>
                                </div>
                                @endforeach
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
                @endforeach

            </div>
        </div>



    </div>
</div>

{!! Form::submit(trans('global.app_update'), ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
@stop